/*
 * @Author: 0x9DEFA478
 * @Date: 2025-07-26 20:18:23
 * @LastEditTime: 2025-07-27 15:40:10
 * @LastEditors: 0x9DEFA478
 * @Description: 
 * 
 */
#ifndef hAtomic_H_Atomic_Empty_HPP_
#define hAtomic_H_Atomic_Empty_HPP_
#include "H_Type.hpp"




namespace H{

  namespace Atomic{

#if __cplusplus >= 202000L
    template<class A>
    concept is_Count=requires(A& a,A::Type v){
      A(v);
      v=a.load();
      a.store(v);
      v=a.increment(v);
      v=a.decrement(v);
    };
#endif

    template<typename ValueType>
    class EmptyCount{
      public:
        using Type=ValueType;
      public:
        EmptyCount(ValueType value):value(value){}
        ~EmptyCount(){}

        ValueType load(){return value;}
        void store(ValueType value){this->value=value;}
        ValueType increment(ValueType value){
          ValueType r=this->value;
          this->value=r+value;
          return r;
        }
        ValueType decrement(ValueType value){
          ValueType r=this->value;
          this->value=r-value;
          return r;
        }
      private:
        ValueType value;
    };

  }

}




#endif //hAtomic_H_Atomic_Empty_HPP_
